#!/usr/bin/env python

"""
docstring
"""

__author__ = 'rx.wen218@gmail.com'

import unittest
from core import htmlutil 

class HtmlUtilTest(unittest.TestCase):
    def setUp(self):
        pass

    def testSpace(self):
        encode = "hello&nbsp;"
        decode = "hello "
        self.assertEqual(decode, htmlutil.DecodeHtml(encode))
        self.assertEqual(encode, htmlutil.EncodeHtml(decode))

    def testAnd(self):
        encode = "hello&amp;"
        decode = "hello&"
        self.assertEqual(decode, htmlutil.DecodeHtml(encode))
        self.assertEqual(encode, htmlutil.EncodeHtml(decode))

    def testAngleBracket(self):
        encode = "hello&lt;"
        decode = "hello<"
        self.assertEqual(decode, htmlutil.DecodeHtml(encode))
        self.assertEqual(encode, htmlutil.EncodeHtml(decode))

        encode = "hello&gt;"
        decode = "hello>"
        self.assertEqual(decode, htmlutil.DecodeHtml(encode))
        self.assertEqual(encode, htmlutil.EncodeHtml(decode))
     
    def testDoubleQuote(self):
        encode = 'hello&quot;'
        decode = 'hello"'
        self.assertEqual(decode, htmlutil.DecodeHtml(encode))
        self.assertEqual(encode, htmlutil.EncodeHtml(decode))

#    def testDecodeEncodeReverse(self):
#        src = "hello&nbsp;world"
#        dec = htmlutil.DecodeHtml(src)
#        self.assertEqual(src, htmlutil.EncodeHtml(dec))

if __name__ == '__main__':
    unittest.main()
